import java.io.*;

/**
 * @author Macrydy
 * @date 2022/5/12
 *
 * 字符缓冲流
 * 两个特殊方法
 * 1.一行一行读取 readline()
 * 2.换行 newLine()
 *
 * 注意：读取到结束返回null，不是-1
 */
public class BufferDemo {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("F:\\FileDemo\\c.txt"));
        //BufferedWriter bw = new BufferedWriter(new FileWriter("F:\\FileDemo\\c-copy.txt"));

        /*bw.write("手机");
        //换行
        bw.newLine();
        bw.write("平板");
        bw.newLine();
        bw.write("电视");*/

        //一行一行读取
        /*String line = br.readLine();
        String line1 = br.readLine();
        System.out.println(line);
        System.out.println(line1);*/

        //拷贝
        /*char[] chars = new char[1024];
        int len;
        while ((len = br.read(chars)) != -1) {
            bw.write(chars,0,len);
        }*/

        //特有方法：一行一行读取
        // 1.读取不到时返回null  2.不会读取换行符
        String line;
        while ((line=br.readLine())!= null) {
            System.out.println(line);
        }


        //bw.close();
        br.close();
    }

}
